#include<iostream>
#include<vector>
using namespace std;
class Solution0 {
public:
    void moveZeroes(vector<int>& nums) {
        int i=0,j=1;
        while(j<nums.size())
        {
            while(j<nums.size()&&nums[j]==0)j++;
            while(i<j-1&&nums[i]!=0)i++;
            if(!nums[i]&&j<nums.size())swap(nums[i],nums[j]);
            j++;
            i++;
        }
    }
};
class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        int i=0,j=0;
        while(j<nums.size())
        {
            while(j<nums.size()&&nums[j]==0)j++;
            if(nums.size()<=j)break;
            nums[i++]=nums[j++];
        }
        for(;i<nums.size();i++)nums[i]=0;

    }
};
 